﻿using UnityEngine;
using System.Collections;
using UnityEngine.UI;

///<summary>
///<para>Scene:All/NameOfScene/NameOfScene1,NameOfScene2,NameOfScene3...</para>
///<para>Object:N/A</para>
///<para>Description: Sample Description </para>
///</summary>

public class GlobalVariables : MonoBehaviour {

	public static int totalCoins = 100;
	public static int hiScore = 0;

	public struct Item
	{
		public int status; // 0 - locked, 1 - locked, 2 - bought, 3 - equpped
		public int price;
	};

	public static Item[] shopItems; 
	public static int indexOfEquippedItem = 0;
	public static int coinsReward = 200;
	public static bool removeAdsBought = false;
	public static bool allowBannerShowing = true;
	public static bool reduceComponents = false;
	public static bool showWebelinxBanner = true;
	public static float realBannerHeight = 0;
	public static bool allowStartInterstitialToShow = false;
	public static string applicationID = "com.Fidget.Spinner.Wheel.Toy.Neon.Glow";
	// Use this for initialization
	void Awake () 
	{
		DontDestroyOnLoad(gameObject);
		#if UNITY_ANDROID
		applicationID = Application.bundleIdentifier;
		#elif UNITY_IOS
		applicationID = "bundle.ID";
		#endif

		if(PlayerPrefs.HasKey("TotalCoins"))
		{
			totalCoins = PlayerPrefs.GetInt("TotalCoins");
		}
		if(PlayerPrefs.HasKey("HiScore"))
		{
			hiScore = PlayerPrefs.GetInt("HiScore");
		}
	}

	public static void AddCoins()
	{
		totalCoins += coinsReward;
		PlayerPrefs.SetInt("TotalCoins",totalCoins);
		PlayerPrefs.Save();
		Shop.Instance.SetCoinsText();
	}

	public static void FlurryEvent(string eventName, string key, string value)
	{
		#if UNITY_ANDROID
		try
		{
			using (AndroidJavaClass cls_UnityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer")) 
			{
				using (AndroidJavaObject obj_Activity = cls_UnityPlayer.GetStatic<AndroidJavaObject>("currentActivity")) 
				{
					obj_Activity.Call("FlurryEvents",eventName + "#" + key + "#" + value);
				}
			} 
			return;
		}
		catch
		{
			Debug.Log("Error Contacting Android! Flurry call.");
			return;
		}
		#endif
	}

	public void DisableLog(string msg)
	{
		Debug.unityLogger.logEnabled = false;
	}		
}
